<?php
/**
 * Created by PhpStorm.
 * Admininfo: Administrator
 * Date: 2017/12/13
 * Time: 16:37
 */

namespace app\admin\model;
use think\Model;
class Menu extends Model
{
	protected $pk = 'id';
    protected $autoWriteTimestamp = true;
    protected $createTime = 'create_time';
    protected $updateTime = 'last_time';
    protected $insert=[
        'status'=>1,
    ];

    /**
     * @return \think\model\relation\HasMany
     */
	public  function child(){
	  return  $this->hasMany('menu','menu_id')->order('sort asc')->where(['status'=>1]);
	}

    /**
     * @param array $list
     * @return false|\PDOStatement|string|\think\Collection
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @throws \think\exception\DbException
     */
    public  static function getchildlist($list=[]){
	    $where['menu_id']=0;
	    $where['status']=1;
	    if(count($list)){
            $where['id']=['in',$list];
        }
		return self::with('child')->where($where)->order('sort asc')->select();
  }

}